﻿@model IEnumerable<Wicresoft.UnifyShow.Business.EventTypeModel>
@{
    ViewBag.Title = "维护服务事件";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@section ScriptAndCss{
    <link href="../../Content/jquery.treeview.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/css/bsadmin.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.treeview.js" type="text/javascript"></script>
    <script src="../../Scripts/ALL.js" type="text/javascript"></script>
    <script type="text/javascript">
        function  initTheEditor(){
            $("#eventSave","#content").click(function()
            {
              $.post("@Url.Action("Edit", "AdminEvent")",
                        $("#eventEditForm").serialize() + "&TIER3=" + $("#TIER3", "#eventEditForm").val(),
                        function () {
                           alert("更新成功");
                        });
            });
            $("#eventPublish","#content").click(function()
            {
              $.post("@Url.Action("Publish", "AdminEvent")",
                        "id="+$("#eventID","#eventEditForm").val(),
                        function () {
                           alert("发布成功");
                        });
            });
            $("#eventDelete","#content").click(function()
            {
              var isContinue=confirm("你确定要删除此服务？");
              if(isContinue)
              {
              $.post("@Url.Action("Delete", "AdminEvent")",
                        "id="+$("#eventID","#eventEditForm").val(),
                        function () {
                           alert("删除成功");
                           var url="@Url.Action("Tree", "AdminEventMaintain")";
                           $("#tree").load(url,function(){
                           treeView();
                           });
                        });
                        }
            });
            }
        
        function treeView(){
             $("#eventTree").treeview({
                control: "#eventTreeControl",
                persist: "cookie",
                cookieId: "treeview-black_eventTreeMaintaince",
                collapsed: true,
                unique: true
              });
             
            $(".node").click(function (e) {
                var id = $(this).attr("data-id");
                var url="@Url.Action("Edit", "AdminEvent")"+"?eventID="+id;
                $("#content").load(url,function()
                {
                initTheEditor();
                });
                $("#eventID").val(id);
                e.preventDefault();
            });
                  $("#content").empty();
        }
       $(function () {
            treeView();
         });
    </script>
}
<div class="index_lr">
    <input type="hidden" id="eventID" />
    <ul>
        <li class="index_lr4_L">
            <div id="tree">
                @Html.Action("Tree")
            </div>
        </li>
        <li class="index_lr4_R">
            <ul>
                <li class="index_lr4_R">
                    <div class="index_lrA_title ui-icons">
                        <h3>
                            服务事件：</h3>
                    </div>
                    <div id="content">
                    </div>
                </li>
            </ul>
</div>
<div class="clear">
</div>